﻿
using System;
using System.Windows;
//
using System.ComponentModel.Composition;

namespace DailyFx.Studio
{
	using DailyFx.UI;

	[Export (typeof(IWindow))]
	[PartCreationPolicy(CreationPolicy.NonShared)]
	[View (typeof(MainWindow))]
	public class MainViewModel : DailyFx.UI.Window, IPartImportsSatisfiedNotification
	{
	//	/// <summary>
	//	///		System .
	//	/// </summary>
	//	private DailyFxSystem _system;

	//	[Import]
	//	private UI.IMenuManager _menuManager;

	//	[Import]
	//	private UI.IChartManager _chartManager;



		/// <summary>
		///		C'tor .
		/// </summary>
		public MainViewModel()
		{
		}

	//	public DailyFxSystem DailyFxSystem
	//	{
	//		get { return _system; }
	//	}



		private readonly int __MainFlyout = 0;

		public FlyoutViewModel MainFlyout
		{
			get { return (FlyoutViewModel)this.GetFlyout(__MainFlyout); }
		}


	//	public MenuManager MenuManager 
	//	{
	//		get { return this._menuManager as MenuManager; } 
	//	}

	//	public ChartManager ChartManager
	//	{
	//		get { return this._chartManager as ChartManager; }
	//	}


		public void OnFlyout()
		{
			GetFlyout(__MainFlyout).TrySwitch();
		}

		protected override void OnLoaded ()
		{
			base.OnLoaded ();

			//	Window's Title .
			this.Title = "DailyFx.Studio";

			// My dailyfx system .
			// this._system = new DailyFxSystem();

			// Window's flyouts
			var flyout = new FlyoutViewModel();
			this.AddFlyout( flyout);

		}

		protected override void OnViewLoaded( object view)
		{
			//if ( Designer.IfTrue )
			//  return;

			base.OnViewLoaded( view);

			// todo: restore window/ dock layout .
			Window window = GetView() as Window;
		}

		protected override void OnEnabled ()
		{
			base.OnEnabled ();
			// todo:
		}

		protected override void OnDisabled ( bool close )
		{
			base.OnDisabled ( close);
			// the main window is closed .
			if (close)
			{
				// clear the references( AppCmds' MainWindow & MainFlyout, etc.) to this main window .
				// todo: 
			}
		}

		/// <summary>
		///     Called when a part's imports have been satisfied and it is safe to use.
		/// </summary>
		public virtual void OnImportsSatisfied()
		{
			// todo:
		}
	}
}
